package com.woniu.micropropertyserver.configure;

import com.woniu.micropropertyserver.util.StringToDateConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.format.FormatterRegistrar;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ：bb
 * @date ：Created in 2021/1/30 0030
 * @description：
 * @modified By：
 * @version: $
 */
public class SpringMvcConfigure implements WebMvcConfigurer {



    /**
     * 跨域支持
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {

        registry.addMapping("/**")
                .allowedOrigins("*")//允许所有的请求
                .allowCredentials(true).//允许做身份认证
                allowedMethods("GET","POST","PUT","DELETE");//允许支持的跨域方法有哪些

       }

        public  void addFormatters(FormatterRegistry registry){
             registry.addConverter(new StringToDateConverter());
        }
   @Bean
    public StringToDateConverter stringToDateConverter(){
        return new StringToDateConverter();
    }
}
